// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.network.packets;

import java.nio.ByteBuffer;
import zombie.characters.IsoPlayer;
import zombie.core.network.ByteBufferWriter;
import zombie.core.raknet.UdpConnection;
import zombie.network.GameServer;

public class PlayerDataRequestPacket implements INetworkPacket {
    short playerId = -1;

    public void set(short _playerId) {
        this.playerId = _playerId;
    }

    public void process(UdpConnection connection) {
        IsoPlayer isoPlayer = (IsoPlayer)GameServer.IDToPlayerMap.get(this.playerId);
        if (connection.RelevantTo(isoPlayer.x, isoPlayer.y) && !isoPlayer.isInvisible() || connection.accessLevel >= 1) {
            GameServer.sendPlayerConnect(isoPlayer, connection);
        }
    }

    @Override
    public void parse(ByteBuffer b, UdpConnection connection) {
        this.playerId = b.getShort();
    }

    @Override
    public void write(ByteBufferWriter b) {
        b.putShort(this.playerId);
    }
}
